{% extends 'base.html' %}
{% block stylesheet %}
{{ block.super }}
{% endblock%}

{% block javascript %}
{{ block.super }}
<script type="text/javascript">
<!--
//<![CDATA[
$(document).ready(function() {
    var aa;
    $("select").focus(function() {
        //store old value
        aa =  $(this).attr("value");
    });

    $("select").change(function(){
        var value = $(this).attr("value");
        classId = value.split(".")[0];
        boothId = value.split(".")[1];

        var targetUrl = "/base/schedule/set/booth/";
        data = "class=" + classId + "&" + "booth=" + boothId;
        $.ajax({
            type: "POST",
            url: targetUrl,
            data: data,
            dataType: "json",
            success: function(data){
                if(data.status == "success") {
                    alert(data.msg);
                } else {
                    alert(data.msg);
                    var ss= "select option[value=" + aa + "]";
                    $(ss).attr("selected","selected");
                }
            }
        });
    });

    $("input:checkbox").change(function(){
        var classId = $(this).val();
        var cancel = $(this).attr("checked");

        var targetUrl = "/base/schedule/cancel/class/";
        data = "class=" + classId + "&" + "cancel=" + cancel;
        $.ajax({
            type: "POST",
            url: targetUrl,
            data: data,
            dataType: "json",
            success: function(data){
                if(data.status == "success") {
                    alert(data.msg);
                    if(data.cancel == "ture") {
                        $("");
                    } else {

                    }
                } else {
                    alert(data.msg);
                }
            }
        });

    });
});
//]]>
--></script>
{{ block.super }}
{% endblock%}
{% block content %}
<div id="navi">
<ul>
    <li><a href="{% url school_list %}">school list</a></li>
</ul>
</div>

<table>
{% for oneclass in oneclasses %}
    <tr>
        <td><input type="checkbox" {% ifequal oneclass.status 'cancel' %}checked="yes"{% endifequal %} name="cancel_{{ oneclass.id }}" value="{{ oneclass.id }}" ></td>
        <td><span id="{{ oneclass.id }}">{{ oneclass.name }}</span></td>
        <td>
            <select>
                <option {% ifequal oneclass.booth.number 0 %}selected="selected"{% endifequal %} value="">--------</option>
                {% for booth_id in booths %}
                <option {% ifequal oneclass.booth.number booth_id %}selected="selected"{% endifequal %} value="{{ oneclass.id }}.{{ booth_id }}">Booth-{{ booth_id }}</option>
                {% endfor %}
            </select>
        </td>
    </tr>
{% endfor %}
</table>

{% endblock %}